package com.lly.pro.repositories;

import com.lly.pro.entity.HR;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface HRRepository extends JpaRepository<HR,Long> {
    /**
     * 用户名，密码是否正确
     * @Param userName 用户名
     * @Param password 密码
     * @return
     */
    @Query(value = "select count(u) from HR u where u.userName = ?1 and u.password = ?2")
    Integer findByUserNameAndPassword(String userName,String password);

    /**
     * 根据userId查找对应HR信息
     * @Param userId
     * @return
     */
    @Query(value = "select u from HR u where u.userId = ?1")
    HR findByUserId(long userId);

    /**
     * 根据用户名和密码获取userId
     * @Param userName 用户名
     * @Param password 密码
     * @return
     */
    @Query(value = "select u.userId from HR u where u.userName = ?1 and u.password = ?2")
    List findUserId(String userName, String password);

    @Query(value = "select COUNT(u) from HR u where u.userName = ?1 and u.password = ?2")
    Long findByUserIdAndPassword(long userId, String password);
}
